#include <Player.hh>

Player::Player(Window &win) : _Window(win)
{
}

Player::~Player()
{
}

void    Player::Initialize(sf::Sprite &sprite, sf::Vector2f &position)
{
    this->_Sprite = sprite;
    this->_Position = position;
}

void    Player::LoadContent(void)
{

}

void    Player::UnloadContent(void)
{

}

void    Player::Draw(Time time)
{
    std::cout << this->_Window.GetFrameTime() << ":" << time <<"\n";
    this->_Window.Draw(this->_Sprite);
}

void    Player::Update(Time time)
{
}

void            Player::MoveUp()
{
    this->_Sprite.Move(sf::Vector2f(0, -1));
    this->_Position = this->_Sprite.GetPosition();
    if (this->_Position.y < 0)
        this->_Sprite.Move(sf::Vector2f(0, 1));
}

void            Player::MoveDown()
{
    this->_Sprite.Move(sf::Vector2f(0, 1));
    this->_Position = this->_Sprite.GetPosition();
    if (this->_Position.y > 600 - this->_Sprite.GetSize().y)
        this->_Sprite.Move(sf::Vector2f(0, -1));
}

void            Player::MoveRight()
{
    this->_Sprite.Move(sf::Vector2f(1, 0.0));
    this->_Position = this->_Sprite.GetPosition();
    if (this->_Position.x >= 800 - this->_Sprite.GetSize().x)
        this->_Sprite.Move(sf::Vector2f(-1, 0));
}

void            Player::MoveLeft()
{
    this->_Sprite.Move(sf::Vector2f(-1, 0.0));
    this->_Position = this->_Sprite.GetPosition();
    if (this->_Position.x < 0)
        this->_Sprite.Move(sf::Vector2f(1, 0));
}

const sf::Vector2f  &Player::GetPosition(void)
{
    return this->_Position;
}

const sf::Vector2f  &Player::GetSize(void)
{
    return this->_Sprite.GetSize();
}
